/*     */ package com.wgcloud.controller;
/*     */ 
/*     */ import cn.hutool.json.JSONObject;
/*     */ import cn.hutool.json.JSONUtil;
/*     */ import com.wgcloud.entity.FileWarnInfo;
/*     */ import com.wgcloud.entity.FileWarnState;
/*     */ import com.wgcloud.service.AppInfoService;
/*     */ import com.wgcloud.service.DockerInfoService;
/*     */ import com.wgcloud.service.FileWarnInfoService;
/*     */ import com.wgcloud.service.LogInfoService;
/*     */ import com.wgcloud.service.PortInfoService;
/*     */ import com.wgcloud.service.SystemInfoService;
/*     */ import com.wgcloud.util.DateUtil;
/*     */ import com.wgcloud.util.ThreadPoolUtil;
/*     */ import com.wgcloud.util.TokenUtils;
/*     */ import com.wgcloud.util.msg.WarnMailUtil;
/*     */ import com.wgcloud.util.staticvar.BatchData;
/*     */ import java.util.Date;
/*     */ import java.util.Iterator;
/*     */ import javax.annotation.Resource;
/*     */ import org.apache.commons.lang3.StringUtils;
/*     */ import org.slf4j.Logger;
/*     */ import org.slf4j.LoggerFactory;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.RequestBody;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ import org.springframework.web.bind.annotation.ResponseBody;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/agentLogGo"})
/*     */ public class AgentLogGoController
/*     */ {
/*  40 */   private static final Logger logger = LoggerFactory.getLogger(com.wgcloud.controller.AgentLogGoController.class);
/*     */   
/*     */   @Resource
/*     */   private LogInfoService logInfoService;
/*     */   
/*     */   @Resource
/*     */   private SystemInfoService systemInfoService;
/*     */   @Autowired
/*     */   DockerInfoService dockerInfoService;
/*     */   @Autowired
/*     */   FileWarnInfoService fileWarnInfoService;
/*     */   @Autowired
/*     */   AppInfoService appInfoService;
/*     */   @Autowired
/*     */   PortInfoService portInfoService;
/*     */   @Autowired
/*     */   private TokenUtils tokenUtils;
/*     */   
/*     */   @ResponseBody
/*     */   @RequestMapping({"/minTask"})
/*     */   public JSONObject minTask(@RequestBody String paramBean) {
/*  61 */     JSONObject agentJsonObject = (JSONObject)JSONUtil.parse(paramBean);
/*  62 */     logger.debug("agent上报日志监控数据-------------" + agentJsonObject.toString());
/*  63 */     JSONObject resultJson = new JSONObject();
/*  64 */     if (!this.tokenUtils.checkAgentToken(agentJsonObject)) {
/*  65 */       logger.error("token is error");
/*  66 */       resultJson.set("result", "token is error");
/*  67 */       return resultJson;
/*     */     } 
/*  69 */     Date nowtime = DateUtil.getNowTime();
/*     */ 
/*     */     
/*  72 */     try { JSONObject fileWarnInfosJson = agentJsonObject.getJSONObject("fileWarnInfos");
/*  73 */       if (fileWarnInfosJson == null)
/*  74 */       { logger.error("fileWarnList is null");
/*  75 */         resultJson.set("result", "error：fileWarnList is null");
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */         
/* 126 */         return resultJson; }  Iterator<String> iter = fileWarnInfosJson.keySet().iterator(); while (iter.hasNext()) { String id = iter.next(); JSONObject jsonObject = fileWarnInfosJson.getJSONObject(id); String filePath = jsonObject.getStr("filePath"); String fileSize = jsonObject.getStr("fileSize"); String warnRows = jsonObject.getStr("warnRows"); String warnContent = jsonObject.getStr("warnContent"); FileWarnState state = new FileWarnState(); state.setCreateTime(nowtime); state.setFilePath(filePath); state.setFileWarnId(id); state.setWarContent(warnContent); if (!StringUtils.isEmpty(warnContent)) BatchData.FILEWARN_STATE_LIST.add(state);  FileWarnInfo info = new FileWarnInfo(); info.setId(id); info.setCreateTime(nowtime); info.setFileSize(fileSize); info.setWarnRows(warnRows); BatchData.FILEWARN_INFO_LIST.add(info); if (!StringUtils.isEmpty(warnContent)) { Runnable runnable = () -> { try { FileWarnInfo fileWarnInfo = this.fileWarnInfoService.selectById(info.getId()); if (fileWarnInfo != null) WarnMailUtil.sendFileWarnDown(fileWarnInfo, warnContent, true);  } catch (Exception e) { e.printStackTrace(); }  }; ThreadPoolUtil.executor.execute(runnable); }  }  return resultJson; } catch (Exception e) { e.printStackTrace(); return resultJson; } finally { Exception exception = null; }
/*     */   
/*     */   }
/*     */ }


/* Location:              /Users/zhangyongxin/soft-install/wgcloud/wgcloud-v3.3.5/server/bank/wgcloud-server-release.jar!/BOOT-INF/classes/com/wgcloud/controller/AgentLogGoController.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */